<?php
/**
 * Created by PhpStorm.
 * User: LuLingFeng
 * Date: 2017/6/6
 * Time: 11:27
 */

namespace App\Api\Service\Website\Controllers;

use App\Api\Service\Website\Models\AppInfo;
//use App\Api\Foundation\Website\Models\Apps;
//use App\Api\Foundation\Website\Models\Article;
//use App\Api\Foundation\Website\Models\Push;
//use App\Api\Foundation\Website\Models\Role;
//use App\Eloquent\App\User;
//use App\Eloquent\OA\CompanyUser;
//use App\Eloquent\OA\Contacts;
//use App\Eloquent\UserRole;
use Framework\BaseClass\Api\Controller;
use Framework\Services\SMS\Alidayu\AlidayuService;

class IndexController extends Controller
{
//    /**
//     * @author sojo
//     */
//    public function sendSms()
//    {
//        $params = $this->getRequestParameters(['mobile', 'scene', 'binding']);
//
//        $service = new AlidayuService();
//        $result = $service->sendSms($params['mobile'], $params['scene'], $params['binding']);
//
//        if ($result->Code !== 'OK') xThrow(ERR_SERVICE_SMS_ALIDAYU, $result->Code);
//    }
//
//    /**
//     * 推送开关切换
//     * @author sojo
//     * @return array
//     */
//    public function pushSwitch()
//    {
//        $token = app('token')->checkToken();
//        $params = $this->getRequestParameters([], ['switch']);
//
//        $push = new Push();
//        return $push->pushSwitch($token->get('user_id'), $params['switch']);
//    }
//
//    /**
//     * 根据用户角色获取对应的应用列表
//     * @author sojo
//     * @return array
//     */
//    public function getAppsList()
//    {
//        $token = app('token')->checkToken();
//        $params = $this->getRequestParameters([], ['location']);
//
//        $apps = new Apps();
//        return $apps->getAppsListByLocation($token->get('user_id'), $params['location']);
//    }
//
//    /**
//     * 根据用户角色搜索对应的应用
//     * @author sojo
//     * @return array
//     */
//    public function searchApps()
//    {
//        $token = app('token')->checkToken();
//        $params = $this->getRequestParameters(['keyword']);
//
//        $apps = new Apps();
//        $appsList = $apps->searchApps($token->get('user_id'), $params['keyword']);
//
//        $returnData = [];
//        if (!$appsList->isEmpty()) {
//            $returnData['apps'] = [
//                'name' => '应用',
//                'data' => $appsList
//            ];
//        }
//
//        return $returnData;
//    }
//
//    /**
//     * 获取APP服务列表
//     * @author LuLingFeng
//     * @return array
//     */
//    public function serviceList()
//    {
//        if (request()->header('platform') == 'android' && request()->header('version') < '1.4.0') {
//            $response = json_decode('{"status":200,"code":0,"message":"\u8bf7\u6c42\u6210\u529f","data":[{"name":"\u9996\u9875","title":"\u676d\u5dde\u8d22\u5854\u79d1\u6280\u6709\u9650\u516c\u53f8","logo_url":"\/upload\/image\/business\/2018\/q2\/04\/18\/1524019701_23953.png","submenu":[{"id":21,"name":"\u79fb\u52a8\u529e\u516c","url":"http:\/\/jd.100dp.com\/assets\/api\/images\/app-service-icon\/icon-qybg@2x.png"},{"id":22,"name":"\u65b0\u95fb\u8d44\u8baf","url":"http:\/\/jd.100dp.com\/assets\/api\/images\/app-service-icon\/icon-xwck@2x.png"},{"id":23,"name":"\u9700\u6c42\u53d1\u5e03","url":"http:\/\/jd.100dp.com\/assets\/api\/images\/app-service-icon\/icon-fbrw@2x.png"},{"id":24,"name":"\u517c\u804c\u5e94\u8058","url":"http:\/\/jd.100dp.com\/assets\/api\/images\/app-service-icon\/icon-xzgz@2x.png"}]}]}', true);
//            return $response['data'];
//        }
//
//        /*$token = app('token')->checkToken();
//        $role = new Role();
//        return $role->serviceList($token['id'], $token['company_id']);*/
//        $token = app('token')->checkToken();
//        $role = new Role();
//        return $role->serviceList($token['oa_company_id']);
//    }


    /**
     * 获取版本更新信息
     * @author Sojo
     * @param string platform 对应平台：android | ios
     * @param string version 当前APP的版本号
     * @return mixed
     */
    public function versionUpdate()
    {
        $platform = request()->header('platform');
        $version = request()->header('version');

//        $platform = "1";
//        $version = "1.1";

        if (!$platform || !$version) xThrow(ERR_PARAMETER);

        $appInfo = new AppInfo();
        return $appInfo->getVersionUpdateInfo($platform, $version);
    }

//    /**
//     * 获取“关于我的”页面中的信息
//     * @author Sojo
//     * @param string platform 对应平台：android | ios
//     * @param string version 当前APP的版本号
//     * @return array
//     */
//    public function about()
//    {
//        $platform = request()->header('platform');
//        $version = request()->header('version');
//        if (!$platform || !$version) xThrow(ERR_PARAMETER);
//
//        $appInfo = new AppInfo();
//        return $appInfo->getAboutInfo($platform, $version);
//    }
//
//    /**
//     * 返回客服热线
//     * @author LuLingFeng
//     * @return string
//     */
//    public function tel()
//    {
//        return '0579-89131200';
//    }
//
//    public function getInformation()
//    {
//        $params = $this->getRequestParameters(['type']);
//        $article = new Article();
//        return $article->getArticleInfo($params['type']);
//    }
//
//
//    public function jdbSwitch()
//    {
//        $data = [
//          'status' => 200,
//          'code' => 0,
//          'message' => 'ok',
//          'data' => 1
//        ];
//        echo json_encode($data);
//        exit;
//    }
//
//    public function snsApprovalSwitch()
//    {
//        $data = [
//            'status' => 200,
//            'code' => 0,
//            'message' => 'ok',
//            'data' => 0
//        ];
//        echo json_encode($data);
//        exit;
//    }
}